﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace DDOS.Objects
{
    public class BoundingRectangle : BoundingObject
    {
        public BoundingBox boundingBox;

        public BoundingRectangle(float x1, float y1, float x2, float y2)
        {
            boundingBox = new BoundingBox(new Vector3(x1, y1, 0), new Vector3(x2, y2, 0));
        }

        public override void Move(float x, float y)
        {
            boundingBox.Min.X += x;
            boundingBox.Min.Y += y;
            boundingBox.Max.X += x;
            boundingBox.Max.Y += y;
        }

        public override bool Intersects(BoundingObject other)
        {
            if (other.GetType() == typeof(BoundingCircle))
            {
                return boundingBox.Intersects(((BoundingCircle)other).boundingSphere);
            }
            else if (other.GetType() == typeof(BoundingRectangle))
            {
                return boundingBox.Intersects(((BoundingRectangle)other).boundingBox);
            }
            return false;
        }

        public override string ToString()
        {
            return boundingBox.ToString();
        }
    }
}
